package com.ruoyi.hualian.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.hualian.domain.ResultBom;
import com.ruoyi.hualian.service.IHlTimingPulleyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 华链 ERP系统功能
 *
 * @author hujian
 */
@Api(tags = "ERP系统功能")
@RestController
@RequestMapping("huaLian/erp")
public class HuaLianErpController {

    @Autowired
    private IHlTimingPulleyService hlTimingPulleyService;

    /**
     * 往ERP系统导入商品数据
     */
    @ApiOperation("往ERP系统导入商品数据")
    @PostMapping("/commodity/importErp")
    public String commodityImportErp(@ApiParam(name = "filePath", value = "文件路径", required = true) @RequestParam("filePath") String filePath,
                                     @ApiParam(name = "fileName", value = "文件名称", required = true) @RequestParam("fileName") String fileName,
                                     @ApiParam(name = "containBK", value = "材质是否含有B·K", required = true) @RequestParam("containBK") Boolean containBK,
                                     HttpServletResponse response) throws Exception {
        return hlTimingPulleyService.commodityImportErp(filePath, fileName, containBK, response);
    }

    /**
     * ERP系统BOM表批量导入功能生成材料Excel表
     * 材料表
     */
    // @ApiOperation("ERP系统BOM表批量导入功能生成材料Excel表")
    // @PostMapping("/bomMaterial/importErp")
    public List<ResultBom> bomMaterialImportErp(@ApiParam(name = "filePath", value = "文件路径", required = true) @RequestParam("filePath") String filePath,
                                                @ApiParam(name = "fileName", value = "文件名称", required = true) @RequestParam("fileName") String fileName,
                                                HttpServletResponse response) throws Exception {
        // return hlTimingPulleyService.bomMaterialImportErp(filePath, fileName, response);
        return null;
    }

    /**
     * ERP系统BOM表批量导入功能生成挡圈Excel表
     * 挡圈表
     */
    // @ApiOperation("ERP系统BOM表批量导入功能生成挡圈Excel表")
    // @PostMapping("/bomRing/importErp")
    public List<ResultBom> bomRingImportErp(@ApiParam(name = "filePath", value = "文件路径", required = true) @RequestParam("filePath") String filePath,
                                   @ApiParam(name = "fileName", value = "文件名称", required = true) @RequestParam("fileName") String fileName,
                                   HttpServletResponse response) throws Exception {
        // return hlTimingPulleyService.bomRingImportErp(filePath, fileName, response);
        return null;
    }

    /**
     * ERP系统BOM表批量导入功能生成[材料、挡圈]Excel表
     * 材料表、挡圈表
     */
    @ApiOperation("ERP系统BOM表批量导入功能生成[材料、挡圈]Excel表")
    @PostMapping("/bom/importErp")
    public String bomImportErp(@ApiParam(name = "materialFilePath", value = "材料文件路径", required = true) @RequestParam("materialFilePath") String materialFilePath,
                               @ApiParam(name = "materialFileName", value = "材料文件名称", required = true) @RequestParam("materialFileName") String materialFileName,
                               @ApiParam(name = "ringFilePath", value = "挡圈文件路径", required = true) @RequestParam("ringFilePath") String ringFilePath,
                               @ApiParam(name = "ringFileName", value = "挡圈文件名称", required = true) @RequestParam("ringFileName") String ringFileName,
                                       HttpServletResponse response) throws Exception {
        return hlTimingPulleyService.bomImportErp(materialFilePath, materialFileName, ringFilePath, ringFileName, response);
    }

    /**
     * 根据商品编码生成ERP系统具体的所需要的商品信息
     */
    @ApiOperation("根据商品编码生成ERP系统具体的所需要的商品信息")
    @PostMapping("/generateErpCommodityCode")
    public String generateErpCommodityCode(@ApiParam(name = "filePath", value = "文件路径", required = true) @RequestParam("filePath") String filePath,
                                           @ApiParam(name = "fileName", value = "文件名称", required = true) @RequestParam("fileName") String fileName,
                                           HttpServletResponse response) throws Exception {
        return hlTimingPulleyService.generateErpCommodityCode(filePath, fileName, response);
    }

    /**
     * 采购订单挡边价格补充
     */
    @ApiOperation("采购订单挡边价格补充")
    @PostMapping("/purchaseFlangeProblem")
    public String purchaseFlangeProblem(@ApiParam(name = "filePath", value = "文件路径", required = true) @RequestParam("filePath") String filePath,
                                        @ApiParam(name = "fileName", value = "文件名称", required = true) @RequestParam("fileName") String fileName,
                                        HttpServletResponse response) throws Exception {
        return hlTimingPulleyService.purchaseFlangeProblem(filePath, fileName, response);
    }


    /**
     * 采购订单入库Excel表生成
     */
    @ApiOperation("采购订单入库Excel表生成")
    @PostMapping("/purchaseReceipt")
    public String purchaseReceipt(@ApiParam(name = "filePath", value = "文件路径", required = true) @RequestParam("filePath") String filePath,
                                           @ApiParam(name = "fileName", value = "文件名称", required = true) @RequestParam("fileName") String fileName,
                                           HttpServletResponse response) throws Exception {
        return hlTimingPulleyService.purchaseReceipt(filePath, fileName, response);
    }
}

